/* eslint-disable jsx-a11y/anchor-is-valid */
/*
 * @Author: Zhouhai 497675647@qq.com
 * @Date: 2022-11-16 15:56:01
 * @LastEditors: Zhouhai 497675647@qq.com
 * @LastEditTime: 2022-11-22 14:09:35
 */
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
    addRoleOrg,
    listRoleOrg,
    delRoleOrg,
    updateRoleOrg,
} from '@/api/system/roleOrg';
import ResizeTable from '@/components/ResizeTable';
import { useStore } from '@/store';
import { SysRoleOrgDomain } from '@/type.d/system/roleorg';
import { ProColumns } from '@ant-design/pro-components';
import { Popconfirm, Table } from 'antd';
import React, { useEffect, useState } from 'react'

export type RoleOrgProps = {
    dataSources?: SysRoleOrgDomain[],
    onDelete?: (data: SysRoleOrgDomain) => void,
    crops?: [],
    orgOptions: any[]
}


const RoleOrg: React.FC<RoleOrgProps> = (props) => {


    /**
     * 列表字段配置
     */
    const columns: ProColumns<SysRoleOrgDomain>[] = [
        {
            title: '角色id',
            dataIndex: 'roleId',
            valueType: 'digit',
            align: 'left',
            width: '50',
            hideInTable: true,
        },
        {
            title: '组织',
            dataIndex: 'orgId',
            valueType: 'select',
            align: 'left',
            width: '50',
            fieldProps: {
                options: props.orgOptions.map((item) => {
                    return {
                        label: item.title,
                        value: item.key
                    }
                })
            }
        },
        {
            title: '组织类型',
            dataIndex: 'orgType',
            valueType: 'select',
            align: 'left',
            width: '50',
            fieldProps: {
                options: [
                    {
                        label: '公司',
                        value: 'C'
                    },
                    {
                        label: '部门',
                        value: 'D'
                    }
                ]
            },
        },
        {
            title: '组织所属公司',
            dataIndex: 'pkCorp',
            valueType: 'select',
            align: 'left',
            width: '50',
            fieldProps: {
                options: props.orgOptions.map((item) => {
                    return {
                        label: item.title,
                        value: item.key
                    }
                })
            }
        },
        {
            title: '授权人',
            dataIndex: 'createBy',
            valueType: 'text',
            align: 'left',
            width: '50',
        },
        {
            title: '授权时间',
            dataIndex: 'createTime',
            valueType: 'dateTime',
            align: 'left',
            width: '50',
        },
        {
            title: '修改人',
            dataIndex: 'updateBy',
            valueType: 'text',
            align: 'left',
            width: '50',
            hideInTable: true,
        },
        {
            title: '修改时间',
            dataIndex: 'updateTime',
            valueType: 'dateTime',
            align: 'left',
            width: '50',
            hideInTable: true,
        },
        {
            title: '备注',
            dataIndex: 'remark',
            valueType: 'text',
            align: 'left',
            width: '50',
            hideInTable: true,
        },
        {
            title: '操作',
            width: 180,
            key: 'option',
            valueType: 'option',
            render: (_dom: React.ReactNode, entity: SysRoleOrgDomain) => [
                <Popconfirm title="确定要删除数据吗？" okText="是" cancelText="否" onConfirm={() => {
                    props.onDelete?.(entity)
                }}>
                    <a key="delete">删除</a>
                </Popconfirm>

            ],
        },
    ];

    return (
        <ResizeTable<SysRoleOrgDomain>
            dataSource={props.dataSources}
            columns={columns}
            cardBordered
            pagination={false}
            revalidateOnFocus={false}
            options={false}
            rowSelection={{
            }}
        >
        </ResizeTable>
    )
}
export default RoleOrg;